package com.jxtc.enterprise.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;


@Configuration
public class RestTemplateConfig {

    /**
     * 统一配置 RestTemplate 连接和读取超时时间
     */
    @Bean
    public RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        // 设置连接超时时间 5 秒
        factory.setConnectTimeout(5000);
        // 设置读取超时时间 10 秒
        factory.setReadTimeout(10000);
        return new RestTemplate();
    }
}
